package com.twetec.cms.adapter.pc.backend.tag;

import com.google.common.collect.Maps;

import com.twetec.cms.adapter.pc.backend.tag.annotation.TplTag;
import com.twetec.cms.adapter.pc.backend.tag.doc.TagDocObject;
import org.beetl.core.tag.GeneralVarTagBinding;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service("zhkxTest")
@Scope("prototype")
@TplTag("zhkxTest")
public class ZhkxTestTag extends GeneralVarTagBinding {

	@Override
	public void render() {
		System.out.println("PPPPPPPPPPPPPP");

		Map result = Maps.newHashMap();
		String name =  (String) this.getAttributeValue("name");
		String say =  (String) this.getAttributeValue("say");

		result.put("name", name);
		result.put("say", say);

		this.binds(result);
		this.doBodyRender();
	}

	/**
	 * 标签文档
	 * @return
	 */
	public static TagDocObject doc() {
		TagDocObject tagDocObject = new TagDocObject();
		tagDocObject.setTagName("zhkxTest");
		tagDocObject.setDesc("测试标签使用");
		tagDocObject.setExample(
				" <#zhkxTest name=\"张三\" say=\"Hello World\" var=\"data\">\n" +
				"        <h1>${data.name!} : ${data.say!}</h1>\n" +
				"      </#zhkxTest>");

		tagDocObject.setParamDesc("name: 名称\n" +
				"say: 说的内容\n" +
				"--------- var: 标签的数据结果集 ---------\n" +
				"name: 名称\t\t\n" +
				"say: 名称");

		tagDocObject.setOtherDesc("无");

		return tagDocObject;
	}

}
